from data_source.statistics_for_exams import ScoreAnalysis
from data_source.statistics_for_exams import ContrastScores
from data_source.statistics_for_exams import RankDistribution


class MyException(object):
    def __init__(self):
        import traceback
        import logging
        logging.basicConfig(
            level=logging.DEBUG,
            filename='D:\\mylog\\error.log',
            format='%(asctime)s %(levelname)s\n %(message)s',
            datefmt='%Y-%m-%d %H:%M:%S'
        )
        logging.error(traceback.format_exc())
        logging.info(msg=exam_processed)


# 输入要处理的文件路径及文件名
# filepath = r'D:\年级管理数据\高2021级\高二下\高二上期末考试\高二上期末考试成绩数据.xlsx'
# filepath = r'D:\年级管理数据\高2021级\高二上\高三上\高三上期半期考试成绩.xlsx'
filepath = r'D:\年级管理数据\高2021级\高一下\高一上期末考试\高2021级高一（上）期末考试总成绩表.xlsx'

file_path_1 = r'D:\年级管理数据\高2021级\高一下\高一下期末考试成绩分析\十一中\高一年级期末考试总分成绩.xlsx'

# 按有效分统计，在此输入相应有效分，分文科和理科分别输入
ScoreAnalysis.arts_scores = [92, 70, 77, 54, 41, 39, 373]  # 文科中线
# ScoreAnalysis.arts_scores = [97,89,95,64,52,54,451]  # 文科高线

ScoreAnalysis.science_scores = [92, 70, 77, 24, 21, 27, 311]  # 理科中线
# ScoreAnalysis.science_scores = [97,89,95,38,40,46,405]  # 理科高线
# 输入要计算的学科前N名：
# ScoreAnalysis.top_n = 5  # 计算前5名
# 输入每个考室的人数：
ScoreAnalysis.numbers_in_room = 35  # 每个考室35人

ContrastScores.path_one = filepath
# 输入上一次考试成绩文件路径入文件名，生成两次考试对比表
# ContrastScores.path_two = r'D:\年级管理数据\高2021级\高一下\高一下期末考试成绩分析\十一中\高一年级期末考试总分成绩.xlsx'
ContrastScores.path_two = r'D:\年级管理数据\高2021级\高二上\高二上半期考试成绩分析\高2021级半期考试成绩数据.xlsx'

exam_processed = ScoreAnalysis(filepath)
rank_range = RankDistribution(filepath, file_path_1)

if __name__ == '__main__':
    @exam_processed.make_directory
    @exam_processed.title_lines
    @exam_processed.use_time
    def main():
        exam_processed.show_menu()
        rank_range.main()
        MyException()


    # 执行计算：
    main()
